import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "../src/assets/styles/reset.css"
import "../src/assets/icon/iconfont.css"

Vue.config.productionTip = false;
Vue.use(ElementUI)

import "./utils/digui"

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");

router.beforeEach((to,from,next)=>{
  let token =localStorage.getItem("myToken")
  //如果有token代表登陆过了，放行
  if(token){
    next()
  }else{
    if(to.path == "/"){
      next()
    }else{
      next({path:"/"})
    }
  }
})
